//
//  XLAnchorCommitHeaderCell.m
//  XiangLove
//
//  Created by 李传坤 on 2018/4/9.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLAnchorCommitHeaderCell.h"
#import "XLDownloadImageTool.h"
@implementation XLAnchorCommitHeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self addheaderView];
    }
    return self;
}

- (void)addheaderView {
    
    self.headerImageview = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.headerImageview setBackgroundImage:[UIImage imageNamed:@"home_but_shangchuan_n"] forState:UIControlStateNormal];
    [self.headerImageview addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_headerImageview];
    
    
    self.coverImageview = [UIButton buttonWithType:UIButtonTypeCustom];
    self.coverImageview.backgroundColor = self.headerImageview.backgroundColor =  [UIColor clearColor];
    [self.coverImageview addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
//    [self.coverImageview setBackgroundImage:[UIImage imageNamed:@"home_but_shangchuan_n"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.coverImageview];
    
    
    self.tittleLabel = [[UILabel alloc] init];
    self.tittleLabel.textColor = [UIColor blackColor];
    _tittleLabel.font = [UIFont systemFontOfSize:16.0f];
    _tittleLabel.text = @"上传真人照片和视频";
    [self.contentView addSubview:_tittleLabel];
    [_tittleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(18);
        make.left.equalTo(self.headerImageview.mas_left);
        make.size.mas_equalTo(CGSizeMake(300, 20));
    }];

    
    self.headerLabel1 = [[UILabel alloc] init];
    self.headerLabel1.textColor = [UIColor darkGrayColor];
    _headerLabel1.font = [UIFont systemFontOfSize:13.0f];
    _headerLabel1.text = @"上传真人照片";
    _headerLabel1.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_headerLabel1];
    
    
    self.headerLabel2 = [[UILabel alloc] init];
    self.headerLabel2.textColor = [UIColor darkGrayColor];
    _headerLabel2.font = [UIFont systemFontOfSize:13.0f];
    _headerLabel2.text = @"上传视频(时长10-15s)";
    _headerLabel2.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_headerLabel2];
    
   
}
- (void)clickButton:(UIButton *)button{
    if (button.tag == 100 ||button.tag == 200) {
        if ([_delagate respondsToSelector:@selector(uploadHeaderAndCover:butonTag:label1:label2:)]) {
            [_delagate uploadHeaderAndCover:_headerImageview butonTag:_headerImageview.tag label1:_headerLabel1 label2:_headerLabel2];
        }
    }else if (button.tag == 101 ||button.tag == 201) {
        if ([_delagate respondsToSelector:@selector(uploadHeaderAndCover:butonTag:label1:label2:)]) {
            [_delagate uploadHeaderAndCover:_coverImageview butonTag:_coverImageview.tag  label1:_headerLabel1 label2:_headerLabel2];
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
